from configparser import RawConfigParser
import os
import zipfile

def read_config_ini(configPath):
    '''读取ini文件'''
    config = RawConfigParser()
    config.read(configPath,encoding='utf-8')
    return config


def make_zip(localPath, pname):
    '''打包zip'''
    zipf = zipfile.ZipFile(pname, 'w',zipfile.ZIP_DEFLATED)
    pre_len = len(os.path.dirname(localPath))
    for parent, dirnames, filenames in os.walk(localPath):
        for filename in filenames:
            pathfile = os.path.join(parent, filename)
            arcname = pathfile[pre_len:].strip(os.path.sep)
            zipf.write(pathfile, arcname)
    zipf.close()
    return pname
def file_all_dele(path):
    '''删除所有文件'''
    for filename in os.listdir(path):
        os.unlink(os.path.join(path,filename))

if __name__ == "__main__":
    from Base.basePath import BasePath
    a = read_config_ini(BasePath.CONFIG_FILE)
    print(a['WEB自动化配置']['browser'])
